﻿Imports QLBH.GlobalClass
Imports System.Text
Public Class uerMainHeThong

    Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
        Dim tenF As String = Me.Name + ".xml"
        GlobalFunction.GhiTenControlToXML(Me, tenF)
        MessageBox.Show("Succsesfull", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub calVLichLamViec_ItemClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calVLichLamViec.ItemClick
        Dim a As DateTimePicker = New DateTimePicker()
        calVLichLamViec.Controls.Add(a)
    End Sub

    Private Sub btnMapIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMapIt.Click
        Try
            Dim street As String = String.Empty
            Dim city As String = "Ho Chi Minh" 'String.Empty
            Dim state As String = "VN" 'String.Empty
            Dim zip As String = String.Empty

            Dim queryAddress As New StringBuilder()
            queryAddress.Append("http://maps.google.com/maps?q=")

            ' build street part of query string
            'If txtStreet.Text <> String.Empty Then
            '    street = txtStreet.Text.Replace(" ", "+")
            '    queryAddress.Append(street + "," & "+")
            'End If

            ' build city part of query string
            If txtCity.Text <> String.Empty Then
                city = txtCity.Text.Replace(" ", "+")
                queryAddress.Append(city + "," & "+")
            End If

            ' build state part of query string
            If txtState.Text <> String.Empty Then
                state = txtState.Text.Replace(" ", "+")
                queryAddress.Append(state + "," & "+")
            End If

            ' build zip code part of query string
            'If txtZipCode.Text <> String.Empty Then
            '    zip = txtZipCode.Text.ToString()
            '    queryAddress.Append(zip)
            'End If

            ' pass the url with the query string to web browser control
            webBrowser1.Navigate(queryAddress.ToString())

        Catch ex As Exception

            MessageBox.Show(ex.Message.ToString(), "Unable to Retrieve Map")

        End Try
    End Sub

    Private Sub btnMapLatLong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMapLatLong.Click

        If txtLat.Text = String.Empty Or txtLong.Text = String.Empty Then
            MessageBox.Show("Supply a latitude and longitude value.", "Missing Data")
        End If

        Try
            Dim lat As String = String.Empty
            Dim lon As String = String.Empty

            Dim queryAddress As New StringBuilder()
            queryAddress.Append("http://maps.google.com/maps?q=")

            ' build latitude part of query string
            If txtLat.Text <> String.Empty Then
                lat = txtLat.Text
                queryAddress.Append(lat + "%2C")
            End If

            ' build longitude part of query string
            If txtLong.Text <> String.Empty Then
                lon = txtLong.Text
                queryAddress.Append(lon)
            End If

            webBrowser1.Navigate(queryAddress.ToString())

        Catch ex As Exception

            MessageBox.Show(ex.Message.ToString(), "Error")

        End Try
    End Sub
End Class
